@namespace AntDesign
@inherits AntDomComponentBase

<div class="@ClassMapper.Class" style="@Style" id="@Id">
    @if (!string.IsNullOrWhiteSpace(Avatar) || AvatarTemplate != null)
    {
        <div class="ant-card-meta-avatar">
            @if (AvatarTemplate != null)
            {
                @AvatarTemplate
            }
            else
            {
                <Avatar Src="@Avatar" />
            }
        </div>
    }

    @if (!string.IsNullOrWhiteSpace(Title) || TitleTemplate != null
            || !string.IsNullOrWhiteSpace(Description) || DescriptionTemplate != null)
    {
        <div class="ant-card-meta-detail">
            @if (!string.IsNullOrWhiteSpace(Title) || TitleTemplate != null)
            {
                <div class="ant-card-meta-title">
                    @if (TitleTemplate != null)
                    {
                        @TitleTemplate
                    }
                    else
                    {
                        @Title
                    }
                </div>
            }
            @if (DescriptionTemplate != null)
            {
                @DescriptionTemplate
            }
            else
            {
                @Description
            }
        </div>
    }
</div>

@code{

    [Parameter]
    public string Title { get; set; }

    [Parameter]
    public RenderFragment TitleTemplate { get; set; }

    [Parameter]
    public string Description { get; set; }

    [Parameter]
    public RenderFragment DescriptionTemplate { get; set; }

    [Parameter]
    public string Avatar { get; set; }

    [Parameter]
    public RenderFragment AvatarTemplate { get; set; }

    protected override void OnInitialized()
    {
        base.OnInitialized();
        ClassMapper.Add("ant-card-meta");
    }

}
